package com.breeze.components.core.exception;

import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 业务异常
 *
 * @author breeze
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class CommonException extends RuntimeException {

  @Serial private static final long serialVersionUID = 1L;

  /** 错误码 */
  private Integer code;

  /** 错误提示 */
  private String message;

  /** 错误明细，内部调试错误 */
  private String detailMessage;

  public CommonException(String message) {
    this.message = message;
  }

  public CommonException(String message, Integer code) {
    this.message = message;
    this.code = code;
  }

  @Override
  public String getMessage() {
    return message;
  }

  public CommonException setMessage(String message) {
    this.message = message;
    return this;
  }

  public CommonException setDetailMessage(String detailMessage) {
    this.detailMessage = detailMessage;
    return this;
  }
}
